package swap;

import org.junit.Test;

public class Swap2 {
	//定义一个对象，对象里面包含一个值；
	class Int {
		public int num;
		public Int(int num) {
			super();
			this.num = num;
		}
	}
	@Test
	public void fun() {
		Int x = new Int(1);
		Int y = new Int(2);
		System.out.println(x);
		swap(x, y);
		System.out.println("x: " + x.num + ";y: " + y.num);
	}
	public void swap(Int x, Int y) {
		int temp = x.num;
		x.num = y.num;
		y.num = temp;
	}
	
}
